<?php
$base = "http://" . $_SERVER['SERVER_NAME'];
#api db
$apiDb = new Admin_Model_Api();
$facebookApi = $apiDb->getApiByName('facebook');
$facebookKey = $facebookApi[0]['api_key'];
$locale = $_SESSION['temp_creation']['locale'];

switch ($locale) {
    case 'en_US':
        $enUs = true;
        break;
    case 'de_DE':
        $deDE = true;
        break;
    case 'fr_FR':
        $frFR = true;
        break;
    case 'gu_IN':
        $guIn = true;
        break;
    default:
        break;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html lang="en"  xmlns:fb="http://ogp.me/ns/fb#" >
    <head>        
        <meta name="viewport" content="width=device-width, initial-scale=1.0"></meta>

        <meta name="description" content=""></meta>
        <meta name="author" content=""></meta>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8"></meta>
        <!-- Le styles -->
        <script src="<?= $base ?>/bootstrap/js/jquery.min.js"></script>        
        <script src="//ajax.googleapis.com/ajax/libs/jqueryui/1.10.3/jquery-ui.min.js"></script>
        <link href="<?= $base ?>/bootstrap/css/jquery.multiselect.css" rel="stylesheet" />
        <link href="<?= $base ?>/bootstrap/css/bootstrap.css" rel="stylesheet" />
        <link href="http://code.jquery.com/ui/1.10.3/themes/smoothness/jquery-ui.css" rel="stylesheet" />
        <link href="<?= $base ?>/bootstrap/css/frontpage2521.css" rel="stylesheet" />
        <script src="<?= $base ?>/bootstrap/js/bootstrap.js"></script>             
        <script src="<?= $base ?>/bootstrap/js/jquery.multiselect.js"></script>             
        <script src="<?= $base ?>/bootstrap/js/jquery.unobtrusive-ajax.min8699.js"></script>
        <style type="text/css">
            body {
                padding-top: 60px;
                padding-bottom: 40px;
            }
            .dropdown-backdrop {
                position: static;
                top: 0;
                right: 0;
                bottom: 0;
                left: 0;
                z-index: 990;
            }
        </style>
        <link href="<?= $base ?>/bootstrap/css/bootstrap-responsive.css" rel="stylesheet">

            <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
            <!--[if lt IE 9]>
              <script src="../assets/js/html5shiv.js"></script>
            <![endif]-->

            <!-- Fav and touch icons -->    
            <!--<link rel="shortcut icon" href="../assets/ico/favicon.png">-->
    </head>

    <body>

        <div class="navbar navbar-inverse navbar-fixed-top">
            <div class="navbar-inner">
                <div class="container">
                    <button type="button" class="btn btn-navbar" data-toggle="collapse" data-target=".nav-collapse">
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                        <span class="icon-bar"></span>
                    </button>
                    <a class="brand" href="<?= $this->url(array(), 'home'); ?>"><i class="icon-map-marker icon-white"></i> <?= $this->translate('project_title'); ?></a>
                    <div class="nav-collapse collapse">
                        <ul class="nav pull-right">                            
                            <li key="home"><a href="<?= $this->url(array(), 'home'); ?>"><i class="icon-home icon-white"></i> <?= $this->translate('home'); ?></a></li>
                            <li key="search"><a href="<?= $this->url(array(), 'search'); ?>"><i class="icon-white icon-search"></i> <?= $this->translate('search_property'); ?></a></li>
                            <li key="about"><a href="<?= $this->url(array(), 'about'); ?>"><i class="icon-white icon-info-sign"></i> <?= $this->translate('about'); ?></a></li>
                            <?php
                            $userValidation = new Validations_User();
                            $valid = $userValidation->hasidentity();
                            if ($valid && $userValidation->getUserTypeId() == 2) {
                                $userID = $userValidation->getUserId();
                                $userDb = new Users_Model_Users();
                                $user = $userDb->getUser($userID);
                                $username = $user[0]['name'];
                                $userEmail = $user[0]['email'];
                                $showName = ($username == null) ? $userEmail : $username;
                                ?>
                                <li class="dropdown">
                                    <a href="#" key="user-index" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-white icon-user"></i> <?=$this->translate('welcome');?>, <?= $showName; ?> <b class="caret"></b></a>
                                    <ul class="dropdown-menu">
                                        <li><a href="<?= $this->url(array(), 'createad'); ?>"><i class="icon-map-marker"></i> <?= $this->translate('create_property_ad') ?></a></li>
                                        <li><a href="<?= $this->url(array(), 'showuserads'); ?>"><i class="icon-list-alt"></i> <?= $this->translate('ur_prosted_ad'); ?></a></li>
                                        <li><a href="<?= $this->url(array(), 'show-message'); ?>"><i class="icon-envelope"></i> <?= $this->translate('inquiries'); ?></a></li>
                                        <li><a href="<?= $this->url(array(), 'search-setting'); ?>"><i class="icon-wrench"></i> <?= $this->translate('search_settings'); ?></a></li>
                                        <li class="divider"></li>
                                        <li><a href="<?= $this->url(array(), 'userprofile'); ?> "><i class="icon-user"></i> <?= $this->translate('user_profile'); ?></a></li>
                                        <li><a href="<?= $this->url(array(), 'userprofileupdate'); ?>"><i class="icon-edit"></i> <?= $this->translate('edit_profile') ?></a></li>
                                        <li><a href="<?= $this->url(array(), 'userpassword'); ?>"><i class="icon-lock"></i> Edit Password</a></li>
                                        <li class="divider"></li>
                                        <li><a href="<?= $this->url(array(), 'userslogout'); ?>"><i class="icon-remove-circle"></i> <?= $this->translate('logout'); ?></a></li>
                                    </ul>
                                </li>
                            <?php } else { ?>
                                <li key="login"><a href="<?= $this->url(array(), 'userslogin'); ?>"><i class="icon-white icon-ok-sign"></i> <?= $this->translate('login'); ?></a></li>
                            <?php } ?>
                            <li class="dropdown" key="adminsettings"><a href="#" class="dropdown-toggle" data-toggle="dropdown"><i class="icon-white icon-globe"></i> <b class="caret"></b></a>
                                <ul class="dropdown-menu">
                                    <li><a href="?locale=en_US"><img src="/image/locale/en_us.gif" /> en_US <?php
                                            if (isset($enUs)) {
                                                echo "<i class='icon-ok-sign'></i> ";
                                            }
                                            ?></a></li>
                                    <li><a href="?locale=de_DE"><img src="/image/locale/de_de.gif" /> DANISH <?php
                                            if (isset($deDE)) {
                                                echo "<i class='icon-ok-sign'></i> ";
                                            }
                                            ?></a></li>                                   
                                </ul>
                            </li>
                        </ul>
                    </div><!--/.nav-collapse -->
                </div>
            </div>
        </div>

        <div class="container">                                    
            <?php echo $this->layout()->content ?><br/><br/>


            <footer><hr/>
                &copy; SpearBall Inc. 2013 |  <a href="<?= $this->url(array(), 'adminlogin'); ?>">Admin Panel</a> |
                <a href="<?= $this->url(array(), 'mobile-home'); ?>">Mobile Version</a>
            </footer>

        </div> <!-- /container -->
        <div id="fb-root"></div>
        <script>(function(d, s, id) {
                var js, fjs = d.getElementsByTagName(s)[0];
                if (d.getElementById(id))
                    return;
                js = d.createElement(s);
                js.id = id;
                js.src = "//connect.facebook.net/en_US/all.js#xfbml=1&appId=<?= $facebookKey ?>";
                fjs.parentNode.insertBefore(js, fjs);
            }(document, 'script', 'facebook-jssdk'));</script>
    </body>
</html>
